import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_wifi/const/ImgConst.dart';
import 'package:flutter_wifi/const/MyColor.dart';
import 'package:mybase/base/tool/globalMethod/FFScreenValue.dart';
import 'package:mybase/base/widget/layout/FFImageButton.dart';
import 'package:mybase/base/widget/layout/FFLineContainer.dart';
import 'package:mybase/base/widget/layout/FFTextButton.dart';

class TipView extends StatelessWidget {
  String msg;

  TipView({
    super.key,
    required this.msg,
  });

  static Future show(String msg) async {
    return SmartDialog.show(
      displayTime: const Duration(seconds: 1),
      alignment: Alignment.topCenter,
      builder: (ctl) {
        return TipView(
          msg: msg,
        );
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return FFLineContainer(
      direction: Axis.vertical,
      children: [
        FFLineContainer(
          direction: Axis.horizontal,
          crossAxisAlignment: CrossAxisAlignment.center,
          width: globalScreenWidth(context) * 0.4,
          padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 16),
          margin: const EdgeInsets.only(top: 24),
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(4),
            color: MyColor.ff5b4d.withOpacity(0.3),
          ),
          children: [
            FFTextButton(
              isExpand: true,
              text: msg,
              fontSize: 14,
              fontColor: MyColor.ff5b4d,
              maxLines: 10,
            ),
            FFImageButton(
              width: 20,
              heigth: 20,
              // padding: EdgeInsets.symmetric(horizontal: 18),
              image: AssetImage("assets/common/system_close@3x.png"),
              onClick: (){
                SmartDialog.dismiss();
              },
            ),
          ],
        )
      ],
    );
  }
}
